import request from '@/utils/request'

// 获取视频课件列表
export function getVideoList(params) {
  return request({
    url: '/api/video/list',
    method: 'get',
    params
  })
}

// 获取视频课件详情
export function getVideoDetail(id) {
  return request({
    url: `/api/video/${id}`,
    method: 'get'
  })
}

// 获取视频课件评论
export function getComments(id) {
  return request({
    url: `/api/video/${id}/comments`,
    method: 'get'
  })
}

// 提交视频课件评论
export function submitComment(id, data) {
  return request({
    url: `/api/video/${id}/comments`,
    method: 'post',
    data
  })
}

// 获取相关视频课件推荐
export function getRelatedVideos(id) {
  return request({
    url: `/api/video/${id}/related`,
    method: 'get'
  })
}

// 收藏/取消收藏视频课件
export function toggleCollection(id, isCollect) {
  return request({
    url: `/api/video/${id}/collection`,
    method: 'post',
    data: { isCollect }
  })
}

// 获取视频播放地址
export function getVideoUrl(id) {
  return request({
    url: `/api/video/${id}/play-url`,
    method: 'get'
  })
}

// 记录视频观看进度
export function updateWatchProgress(id, data) {
  return request({
    url: `/api/video/${id}/progress`,
    method: 'post',
    data
  })
}

export default {
  getVideoList,
  getVideoDetail,
  getComments,
  submitComment,
  getRelatedVideos,
  toggleCollection,
  getVideoUrl,
  updateWatchProgress
} 